var table1;
$(function () {
    initTime();
    layui.use('table', function () {
        var table = layui.table;
        table1 = table.render({
            elem: '#inOutRecordTable',
            method: 'post',
            contentType: "application/json",
            url: ctx + "/inOutRecord/queryByPage",
            title: '进出记录列表',
            page: true,
            request: {
                pageName: 'currentPage',
                limitName: 'pageSize'
            },
            limit: 10,
            limits: [10, 15, 20, 25, 30],
            height: 'full-120',
            cols: [
                [
                    {
                        title: '序号', width: 50, templet: function (obj) {
                            return obj.LAY_INDEX
                        }
                    },
                    {field: 'name', align: 'center', width: '150', title: '姓名'},
                    {field: 'communityName', align: 'center', width: '200', title: '小区名'},
                    {field: 'phone', align: 'center', width: '150', title: '手机号'},
                    {field: 'inTime', align: 'center', width: '180', title: '进门时间'},
                    {field: 'outTime', align: 'center', width: '180', title: '出门时间'}
                ]
            ]
        });
    });

})

//初始化时间
function initTime() {
    layui.use('laydate', function () {
        var laydate = layui.laydate;
        laydate.render({
            elem: '#dayTime', //指定元素
            format: 'yyyy-MM-dd' //可任意组合
        });
    });
}

//查询
function query() {
    const condition = {
        name: $("#name").val(),
        dayTime: $("#dayTime").val()
    }
    table1.reload({
        where: {
            "condition": condition
        }
    });
}

//清空
function clean() {
    $("#name").val('');
    $("#dayTime").val('');
    query();
    form.render();
}